//
//  EPMMembershipCell.m
//  myXianfeng
//
//  Created by 马继鵬 on 17/5/5.
//  Copyright © 2017年 EPM. All rights reserved.
//

#import "EPMMembershipCell.h"

@interface EPMMembershipCell()
@property (weak,nonatomic) UIControl* membershipCenter;
@property (weak,nonatomic) UIControl* scoreCenter;


@end
@implementation EPMMembershipCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        [self setupUI];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

#pragma mark - 设置界面 -

- (void)setupUI{
    
    //设置会员中心
    UIControl* membershipCenter = [[UIControl alloc]init];
    self.membershipCenter = membershipCenter;
    [self.contentView addSubview:membershipCenter];
    
    [membershipCenter mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.bottom.equalTo(self.contentView);
        make.width.equalTo(self.contentView).multipliedBy(0.5);
        make.height.mas_equalTo(100);
    }];
    
    UIImageView* imgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"memberCenter"]];
    [membershipCenter addSubview:imgView];
    [imgView sizeToFit];
    
    [imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(membershipCenter);
        make.centerX.equalTo(membershipCenter).multipliedBy(0.5);
    }];
    
    UILabel* label = [[UILabel alloc]init];
    label.text = @"会员中心";
    label.font = [UIFont systemFontOfSize:17];
    [membershipCenter addSubview:label];
    
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(imgView).offset(-5);
        make.leading.equalTo(imgView.mas_trailing).offset(17);
    }];
    
    UILabel* desLabel = [[UILabel alloc]init];
    desLabel.text = @"查看会员特权";
    desLabel.font = [UIFont systemFontOfSize:13];
    desLabel.textColor = [UIColor lightGrayColor];
    [membershipCenter addSubview:desLabel];
    
    [desLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(label);
        make.bottom.equalTo(imgView).offset(5);
    }];
    //分割线
    UIView* lineView = [[UIView alloc]init];
    lineView.backgroundColor = [UIColor lightGrayColor];
    [self.contentView insertSubview:lineView aboveSubview:membershipCenter];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self);
        make.width.mas_equalTo(1);
        make.height.equalTo(self.mas_height).multipliedBy(2.0/3);
    }];
    
    //积分中心
    UIControl* scoreCenter  = [[UIControl alloc]init];
    self.scoreCenter = scoreCenter;
    [self.contentView addSubview:scoreCenter];
    
    [scoreCenter mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.trailing.equalTo(self);
        make.leading.equalTo(membershipCenter.mas_trailing);
    }];
    
    UIImageView* scoreImg = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Integral-mall"]];
    [scoreImg sizeToFit];
    [scoreCenter addSubview:scoreImg];
    
    [scoreImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(scoreCenter);
        make.centerX.equalTo(scoreCenter.mas_centerX).multipliedBy(0.5);
    }];
    
    UILabel* scoreLabel = [[UILabel alloc]init];
    [scoreCenter addSubview:scoreLabel];
    scoreLabel.text = @"积分商城";
    scoreLabel.font = [UIFont systemFontOfSize:17];
    
    [scoreLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(scoreImg.mas_trailing).offset(17);
        make.top.equalTo(scoreImg).offset(-5);
    }];
    
    UILabel* scoreDeslabel = [[UILabel alloc]init];
    [scoreCenter addSubview:scoreDeslabel];
    scoreDeslabel.text = @"兑换优惠券";
    scoreDeslabel.font = [UIFont systemFontOfSize:13];
    scoreDeslabel.textColor = [UIColor lightGrayColor];
    [scoreDeslabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(scoreLabel);
        make.bottom.equalTo(scoreImg).offset(5);
    }];
    
    [membershipCenter addTarget:self action:@selector(actionEnterMemberCenter:) forControlEvents:UIControlEventTouchUpInside];
    [scoreCenter addTarget:self action:@selector(actionEnterScoreCenter:) forControlEvents:UIControlEventTouchUpInside];
    
    
}


#pragma mark - 点击事件 -

- (void)actionEnterMemberCenter:(UIControl*)sender{
    
}

- (void)actionEnterScoreCenter:(UIControl*)sender{
    
}

@end
